/***************************************************************************
 *   Copyright (C) 2007 by Alexandre Masselot,,,   *
 *   alex@alex-laptop   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this program; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "utils/massindex.h"
#include "utils/deltamassbuilder.h"

#include "massindexanchordummy.h"
using namespace std;
using namespace bol;


int main(int argc, char **argv){
  MassIndex<MassIndexAnchorDummy, vector<const MassIndexAnchorDummy*>::const_iterator> index(5);
  index.addAnchor(new MassIndexAnchorDummy(1030, "A"));
  index.addAnchor(new MassIndexAnchorDummy(500, "B"));
  index.addAnchor(new MassIndexAnchorDummy(460, "C"));
  index.addAnchor(new MassIndexAnchorDummy(499, "D"));
  index.addAnchor(new MassIndexAnchorDummy(750, "E"));
  index.addAnchor(new MassIndexAnchorDummy(750, "E1"));
  index.addAnchor(new MassIndexAnchorDummy(750, "E2"));
  index.addAnchor(new MassIndexAnchorDummy(1050, "F"));
  index.addAnchor(new MassIndexAnchorDummy(410, "G"));

  index.buildIndex();
  cout<<index;

  DeltaMassBuilder builder;
  index.setTolerance(builder.deltamassInstance("50Da"));
  vector<const MassIndexAnchorDummy*>::const_iterator first;
  vector<const MassIndexAnchorDummy*>::const_iterator last;

  vector<double>ms;
  ms.push_back(500);
  ms.push_back(699);
  ms.push_back(700);
  ms.push_back(500);
  ms.push_back(1000);
  ms.push_back(100);
  ms.push_back(2000);
  for(vector<double>::const_iterator it=ms.begin(); it<ms.end(); it++){
    cout<<"mass close to "<< *it<<"+/-"<< *index.tolerance()<<endl;
    index.getAnchors(*it, first, last);
    for(vector<const MassIndexAnchorDummy*>::const_iterator it2=first; it2<last; it2++){
      cout<< **it2<<endl;
    }
    cout<<endl;
  }
}
